package Tests.ChessPieces;

import java.rmi.RemoteException;

import Models.Player;
import Models.StandardChessPieceModel;
import Models.StandardPlayer;
import Models.StandardPoint2D;
import org.junit.Assert;
import org.junit.Before;
import org.junit.BeforeClass;
import org.junit.Test;

import Controllers.KnightController;
import Models.ChessPieceModel;

public class KnightControllerTest {
	
	private KnightController knightController;
	private Player player;
	

	@BeforeClass
	public static void setUpBeforeClass() throws Exception {
	}

	@Before
	public void setUp() throws Exception {
		
		knightController = new KnightController();
		player = new StandardPlayer();
	}

	@Test
	public void testLegalMove() {
		
		try {
			ChessPieceModel model = new StandardChessPieceModel(player);
			Assert.assertTrue(knightController.legalMove(new StandardPoint2D(1,2), model)); 
			Assert.assertTrue(knightController.legalMove(new StandardPoint2D(2,1), model));
			Assert.assertTrue(knightController.legalMove(new StandardPoint2D(2,-1), model));
			Assert.assertTrue(knightController.legalMove(new StandardPoint2D(1,-2), model));
			Assert.assertTrue(knightController.legalMove(new StandardPoint2D(-1,-2), model));
			Assert.assertTrue(knightController.legalMove(new StandardPoint2D(-2,-1), model));
			Assert.assertTrue(knightController.legalMove(new StandardPoint2D(-2,1), model));
			Assert.assertTrue(knightController.legalMove(new StandardPoint2D(-1,2), model));
			Assert.assertTrue(knightController.legalMove(new StandardPoint2D(1,2), model));
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}
	
	@Test
	public void testIlegalMove() {
		
		try {
			ChessPieceModel model = new StandardChessPieceModel(player);
			Assert.assertFalse(knightController.legalMove(new StandardPoint2D(0,1), model));
			Assert.assertFalse(knightController.legalMove(new StandardPoint2D(4,5), model));
			Assert.assertFalse(knightController.legalMove(new StandardPoint2D(3,1), model));
		} catch (RemoteException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		
	}

	

	
	
	
}
